package cn.org.xuanguang.kepler.hormos.rdb.dml.warrper;

import java.util.HashMap;
import java.util.Map;

/**
 * 针对单一结果，封装成map对象
 * <p>
 * 用法如下
 * </P>
 *
 * @since 3.0
 */
public class SingleMapMapper implements ResultWrapper<Map<String, Object>, Object> {


    private Map<String, Object> result;

    public static SingleMapMapper getInstance() {
        return new SingleMapMapper();
    }

    @Override
    public Map<String, Object> newRowInstance() {
        return new HashMap<>();
    }

    @Override
    public void wrapColumn(ColumnWrapperContext<Map<String, Object>> context) {
        result = context.getRowInstance();
        result.put(context.getColumnLabel(), context.getResult());
    }

    @Override
    public boolean completedWrapRow(Map<String, Object> result) {

        return true;
    }

    @Override
    public Object getResult() {
        return result;
    }
}
